<@override name="content">
<form class="form-horizontal" action="notice/save" method="post">
  <div class="control-group notice <#if titleMsg??>error</#if>">
    <label class="ueditor control-label" for="inputTitle">Title</label>
    <div class="controls">
      <textarea id="inputTitle" name="notice.title" rows="1" cols="120" required></textarea>
      <p class="text-error">${titleMsg!}</p>
    </div>
  </div>
  <div class="control-group notice">
    <label class="control-label" for="inputStartTime">Start Time</label>
    <div class="controls input-append date form_datetime" id="startTime">
      <input size="16" type="text" name="startTime" id="inputStartTime" value="${startTime!}" readonly required>
      <span class="add-on"><i class="icon-th"></i></span>
    </div>
  </div>
  <div class="control-group notice">
    <label class="control-label" for="inputEndTime">End Time</label>
    <div class="controls input-append date form_datetime" id="endTime">
      <input size="16" type="text" name="endTime" id="inputEndTime" value="${endTime!}" readonly required>
      <span class="add-on"><i class="icon-th"></i></span>
    </div>
  </div>
  <div class="control-group notice">
    <label class="ueditor control-label" for="inputContent">Content</label>
    <div class="controls">
      <textarea id="inputContent" name="notice.content" rows="13" cols="120" required></textarea>
    </div>
  </div>
  <div class="control-group">
    <div class="controls">
      <button type="submit" class="btn btn-primary">Submit</button>
      <button type="reset" class="btn btn-info">Reset</button>
    </div>
  </div>
</form>
</@override>
<@override name="scripts">
  <link href="assets/bootstrap-wysihtml5/bootstrap-wysihtml5-0.0.2.css" rel="stylesheet" type="text/css"></link>
  <script src="assets/bootstrap-wysihtml5/lib/wysihtml5-0.3.0.min.js"></script>  
  <script src="assets/bootstrap-wysihtml5/bootstrap-wysihtml5-0.0.2.min.js"></script>
     
  <link href="assets/bootstrap-datetimepicker/css/datetimepicker.css" rel="stylesheet">
  <script type="text/javascript" src="assets/bootstrap-datetimepicker/js/bootstrap-datetimepicker.min.js" charset="UTF-8"></script>

  <script type="text/javascript">
    $('#inputContent').wysihtml5({
      html: true
    });
    
    $('#startTime').datetimepicker({
        format: "yyyy-mm-dd hh:ii",
        autoclose: true,
        todayBtn: true,
        pickerPosition: "bottom-left",
        //minuteStep: 30

    }).on('changeDate', function(ev){
        var time = ev.date.valueOf();
        var date = formatDate(new Date(time + 300000));
        var endDate = formatDate(new Date(time));
        
        $('#inputEndTime').val(endDate);
        $('#endTime').datetimepicker('setStartDate', date);
    });

    $("#endTime").datetimepicker({
        format: "yyyy-mm-dd hh:ii",
        autoclose: true,
        todayBtn: true,
        pickerPosition: "bottom-left",
        startDate: "${startTime!}",
        //minuteStep: 30
    });

    function formatDate(now) {
      var year=now.getUTCFullYear();
      var month=now.getUTCMonth()+1; month = (month < 10 ? '0' : '') + month;
      var date=now.getUTCDate(); date = (date < 10 ? '0' : '') + date;
      var hour=now.getUTCHours(); hour = (hour < 10 ? '0' : '') + hour;
      var minute=now.getUTCMinutes(); minute = (minute < 10 ? '0' : '') + minute;
      return year+"-"+month+"-"+date+" "+hour+":"+minute;
    }
    function getLocalTime(time) {     
       return new Date(time).toLocaleString().replace(/年|月/g, "-").replace(/日/g, " ");      
    }
  </script>
</@override>
<@extends name="../common/_layout.html" />
